package controller;

import javax.swing.JDialog;
import javax.swing.JOptionPane;

import view.GenericView;
import view.VotacionView;

public class VotacionController  implements GenericController {
	
	private StartController parentController;

	public VotacionController(StartController startController) {
		this.parentController = startController;
	}

	public void handleButtonCancelar() {
		getView().hideWindow();
		this.parentController.getView().showWindow();
	}

	public void voteFor(String nombreCandidato) {
		this.parentController.getManager().getCandidate(nombreCandidato).addVote();
		JDialog dialogo = new JDialog(); 
		JOptionPane.showMessageDialog(dialogo,"Voto notificado", "Notificacion",
	                    JOptionPane.INFORMATION_MESSAGE);
		this.parentController.getManager().guardar();
		this.getView().hideWindow();
		this.parentController.getView().showWindow();
	}

	@Override
	public GenericView getView() {
		return VotacionView.getInstance();
	}

	@Override
	public GenericController getParentController() {
		return parentController;
	}

}
